<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>首页</title>
  <link rel="stylesheet" href="/public/main.css">
</head>

<body>
  <div class="content">
    <h1>注册</h1>
    <table>
      <tbody>
        <tr>
          <td>账号:</td>
          <td>
            <input type="text" name="username">
          </td>
        </tr>
        <tr>
          <td>密码:</td>
          <td>
            <input type="password" name="password">
          </td>
        </tr>
        <tr>
          <td>再输入一次密码:</td>
          <td>
            <input type="password" name="rePassword">
          </td>
        </tr>
        <tr>
          <td>
            <button id="register">注册</button>
          </td>
          <td>
            <button id="login">登陆</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script>
    $('#register').click(function () {
      $.ajax({
        type: 'post',
        url: '/api/user/register',
        data: {
          username: $('.content').find('[name=username]').val(),
          password: $('.content').find('[name=password]').val(),
          rePassword: $('.content').find('[name=rePassword]').val()
        },
        dataType: 'json',
        success: function (result) {
          console.log(result);
        }
      })
    })
  </script>
</body>

</html>